.. _`Json Calculator`: .. _`org.sysess.sympathy.jsoncalculator`: Json Calculator ``````````````` .. image:: json_calculator.svg :width: 48 Apply a user-defined function on Json entries matching a query. Documentation ::::::::::::: For more information about how to write Json queries, see :ref:`appendix_json_queries`. If :guilabel:`Match anywhere` is not checked (the default) the query must match starting at the root of the Json structure. E.g. the query ``articles`` only matches if the root entry is a dictionary containing the key "articles". Conversely, if :guilabel:`Match anywhere` is checked the query ``articles`` can matches the key "articles" in any dictionary in the whole structure. It can even match at several places despite the query just being a simple key. The calculation --------------- The supplied python function can be entered either as a lambda expression or as a function definition using ``def``. It is called once for each matching entry in the Json structure. The matching entry is passed to the function and is replaced in the output by whatever is returned by the function. Definition :::::::::: Input ports ----------- **input** json Input Output ports ------------ **output** json Output Configuration ------------- **Match anywhere** (anywhere) Match the query at any position in the Json structure. **Calculation** (calculation) Calculation function (either a lambda or def) which takes a Json entry as only argument and returns a new Json entry. **Query** (query) Query for selecting entries in the Json structure. The visual editor can help you create a query which selects a single entry. The query can then be edited manually to include slices (e.g. [2:4]) or patterns (e.g. some*key) which will select multiple entries. For more details see the node's documentation. Related nodes ------------- * :ref:`org.sysess.sympathy.create.createjson` Examples -------- * :download:`json_examples.syx ` Implementation -------------- .. automodule:: node_filterjson :noindex: .. class:: JsonCalculator :noindex: